import 'package:flutter/material.dart';
import 'package:flutter_shop/model/details.dart';
import 'package:flutter_shop/provide/details_provide.dart';
import 'package:provide/provide.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';


class DetailsTopArea extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  Provide<DetailsInfoProvide>(
      builder: (context,child,detailsInfoProvide){

        GoodInfo goodsInfo=detailsInfoProvide.detailsModel.data.goodInfo;

        if(goodsInfo!=null){
          return Container(
            color: Colors.white,
            child: Column(
              children: <Widget>[
                _goodsImage(goodsInfo.image1),
                _goodName(goodsInfo.goodsName),
                _goodNumber(goodsInfo.goodsSerialNumber),
                _goodPic(goodsInfo.oriPrice),
              ],
            ),
          );
        }else{
          return Text('加载中...');
        }
      },
    );
  }

  //商品图片
  Widget _goodsImage(String url){
    return Container(
      child: Image.network(url,
      width: ScreenUtil().setWidth(740),),
    );
  }

  //商品名称
  Widget _goodName(String name){

    return Container(
      padding: EdgeInsets.only(left: 15.0),
      width: ScreenUtil().setWidth(740),
      child: Text(
        name,
        style: TextStyle(
          fontSize: ScreenUtil().setSp(30.0),
        ),
        overflow: TextOverflow.ellipsis,
        maxLines: 1,
      ),
    );
  }

  //商品编号
  Widget _goodNumber(String num){

    return Container(
      width: ScreenUtil().setWidth(740),
      padding: EdgeInsets.only(left: 15.0,top: 8.0),
      child: Text(
        '${num}',
        style: TextStyle(fontSize: ScreenUtil().setSp(25.0),color: Colors.grey),
      ),
    );
  }

  Widget _goodPic(double pic){

    return Container(
      width: ScreenUtil().setWidth(740),
      padding: EdgeInsets.only(left: 15.0,top: 8.0),
      child: Text(
        '￥${pic}',
        style: TextStyle(fontSize: ScreenUtil().setSp(40.0),color: Colors.pink),
      ),
    );
  }



}